package com.hzlj.position.dbsync.liaoning.listener;

import com.fz.common.kafka.annotation.KafkaListenerRetry;
import com.hzlj.position.dbsync.liaoning.rest.LnSqjzRest;
import com.hzlj.position.locate.common.dto.position.PositionHandleDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.hzlj.position.config.common.constant.Topic.POSITION_HANDLE;


@Slf4j
@Component
public class LnSqjzPositionHandleListener {
    @Resource
    private LnSqjzRest lnSqjzRest;

    @KafkaListenerRetry(enable = false)
    @KafkaListener(topics = {POSITION_HANDLE})
    public void positionHandle(ConsumerRecord<String, PositionHandleDTO> record) {
        PositionHandleDTO handle = record.value();
        if (handle == null || Boolean.TRUE.equals(handle.getFromOpenApi())) {
            return;
        }
        lnSqjzRest.positionHandle(handle);
    }


}
